

<if condition="$cartList">
<div class="container ">
	<div class="orderLine clearfix">
		<div class="col-xs-6 onhover">1.<b>Your Cart</b></div>
		<div class="col-xs-6">2.<b>Pay &amp; Submit</b></div>
	</div>
</div>

<div class="container">



<div class="carttop">
<div>
<select name="currency" title="Select Your Currency" onchange="set_exchange_rate(this.value)">
<volist name="exchange_rate_list" id="v"  >
    <option value="{$v.id}"  <if condition="$Think.session.exchange_rate_id eq $v[id]">selected="selected"</if>>{$v.title}</option></volist>
    </select></div>

                    <a href="javascript:history.go(-1);">Keep shopping</a>
	</div>
    


<p class="cartred">This Item has already been placed in your shopping cart.To adjust the quantity of items in your cart please usr the form below.</p>

</div>
</if>

<if condition="empty($cartList)">


    <div class="container usercenter">
        <div class="page-title">
            <h1>Message Notification</h1>
        </div>
        <div class="cart-empty">
       
                    <p>No information in your shopping cart</p>
        
            <p>Click <a href="/" style=" color:#CC0066;">here</a> to continue shopping.</p>
        </div>
    </div>

</if>

<if condition="$cartList">
  <if condition="$promname">
 <div class="container">

        <b class="cart_tag">Promotions：</b>
        <span class="content_tag">
          <select name="hd_id" id="hd_id" onchange="ajax_cart_list()" style="margin-right:10px;">
          <foreach name="promname" item="v1" key="k1" >
              <option <if condition="$hd_id eq $v1[id]"> selected="selected" </if> value="{$v1[id]}">{$v1[name]}</option>
          </foreach>
          </select>
         </span>


       </div>
        </if>

</if>


<if condition="$cartList">
<div class="container checkout-cart-index">
	<div class="col-md-9 cart">

		<div id="shopping-cart-table" class="cart-table">

                 <foreach name="cartList" item="v" key="k" >



					<div class="cartList clearfix">



                    <div class="col-sm-3 col-xs-8">
                    <a href="{:U('Home/Goods/goodsInfo',array('id'=>$v[goods_id]))}" class="product-image" target="_blank"><img src="{$v.goods_id|goods_thum_images=176,176}" ></a>
                    </div>
                    <div class="col-sm-6 col-xs-12">

                        <h3>
                            <!--<input type="checkbox"  name="cart_select[{$v.id}]" <if condition="$v[selected] eq 1" >checked="checked"</if>  value="1" onclick="ajax_cart_list();" <if condition="$v.store_count eq '0'">disabled="disabled" </if>  />-->
                            <a href="{:U('Home/Goods/goodsInfo',array('id'=>$v[goods_id]))}"  target="_blank">{$v.goods_name}</a></h3>
                        <!--{$v.attach|get_attach_show}-->
                        <script type="text/javascript" src="__PUBLIC__/js/jquery.imagePreview.1.0.js"></script>
                        <script type="text/javascript">
                            $(function(){
                                $("a.preview").preview();
                            });
                        </script>
                        <script type="text/javascript" charset="utf-8">
                            $(function(){
                                $("a.preview").click(function() {
                                    if ($(this).hasClass("active")) { return false; }
                                    return false;
                                });
                            });
                        </script>

                        {:get_attach_show($v[attach],1,180)}
                        <div style="clear: both;"></div>
                        <p><a href="{:U('Home/Article/detail',array('article_id'=>21))}">CANCEL &amp; RETURN POLICIES</a></p>
                    </div>
                    <div class="col-sm-3 col-xs-12 text-right">
                        <p><b><span class="price">{$total_price.money_str}{$v.member_goods_price}</span></b>  each</p>
                        <div class="clearfix">
                        <p class="cartNum product-cart-actions">
                            <button type="button" class="cartNumle" onClick="switch_num(-1,{$v.id},{$v.store_count});">-</button>
                            <input value="{$v.goods_num}" name="goods_num[{$v.id}]" id="goods_num[{$v.id}]" readonly size="4" title="Qty" class="cartNumBox" maxlength="12" >
                            <button type="button" class="cartNumPl" onClick="switch_num(1,{$v.id},{$v.store_count});">+</button>
                           <span id="update_3030" class="updatesub"><button>update</button></span>
                        </p>
                            <div class="clearfix"></div>
                            <p><a href="javascript:void(0);" onclick="ajax_del_cart({$v.id});" >REMOVE</a></p>
                        </div>

                        <p></p><h4>Item Total:<span class="price">{$total_price.money_str}{$v.goods_fee}</span></h4><p></p>
                        <p style="display:none;">You Save : $0.00</p>
                    </div>
                </div>

        </foreach>
        </div>



                </div>


	<div class="col-md-3">
        <div class="cartSumBox">
			<h3>CART SUMMARY</h3>
                <table id="shopping-cart-totals-table">
        <colgroup><col>
        <col width="1">
        </colgroup>
        <tfoot>
            <tr>
                <td style="" class="a-right" colspan="1">
                    <strong>Grand Total</strong>
                </td>
                <td style="" class="a-right">
                    <strong><span class="price">{$total_price.money_str}{$total_price.total_fee}</span></strong>
                </td>
            </tr>
        </tfoot>
        <tbody>

            <tr>
                <td style="" class="a-right" colspan="1">
                    Subtotal    </td>
                <td style="" class="a-right">
                    <span class="price">{$total_price.money_str}{$total_price.total_header_fee}</span>    </td>
            </tr>
            <tr>
                <td style="" class="a-right" colspan="1">
                    Saved    </td>
                <td style="" class="a-right">
                    <span class="price">{$total_price.money_str}{$total_price.yh_total}</span>    </td>
            </tr>

        </tbody>
    </table>
			            <ul class="checkout-types">
 <li><p class="cartSub"><input type="submit" class="orderSubPay " value="CHECKOUT" onclick="link_cart2()"></p>
</li>
                                                                    </ul>
            		</div>

		<div class="cartContBox" style="display:none;">
			<h3>Need Help?</h3>
			<div>
				+86-760-879095952<br>Today 9 AM -6PM CT
			</div>
			<p><a href="{:U('Home/Article/detail',array('article_id'=>5))}">Contact Us</a></p>
		</div>
    </div>
</div>

</if>



<script>


    function link_cart2(){
        var hd_id = $('#hd_id').val();
        $('#hd_id_1').val(hd_id);
        $('#form2').submit();
    }







    /**
     * 查询购物车0库存是否可选
     * 购买数量 , 购物车id , 库存数量
     */

    /**
     * 购买商品数量加加减减
     * 购买数量 , 购物车id , 库存数量
     */
    function switch_num(num,cart_id,store_count)
    {
        var num2 = parseInt($("input[name='goods_num["+cart_id+"]']").val());
        num2 += num;
        if(num2 < 1) num2 = 1; // 保证购买数量不能少于 1
        if(num2 > store_count)
        {
            error = "Inventory only "+store_count+" article, You can only buy "+store_count+" article";
            layer.alert(error, {icon: 2});
            num2 = store_count; // 保证购买数量不能多余库存数量
        }

        $("input[name='goods_num["+cart_id+"]']").val(num2);

        ajax_cart_list(); // ajax 更新商品价格 和数量
    }


    /**  全选 反选 **/
    function check_all()
    {
        var vt = $("#select_all").is(':checked');
        $("input[name^='cart_select']").prop('checked',vt);
        // var checked = !$('#select_all').attr('checked');
        // $("input[name^='cart_select']").attr("checked",!checked);
        ajax_cart_list(); // ajax 更新商品价格 和数量
    }


    // ajax 删除购物车的商品
    function ajax_del_cart(ids)
    {
        $.ajax({
            type : "POST",
            url:"{:U('Home/Cart/ajaxDelCart')}",//+tab,
            data:{ids:ids}, //
            dataType:'json',
            success: function(data){
                // alert(data.msg);
                if(data.status == 1)
                    ajax_cart_list(); // ajax 请求获取购物车列表
            }
        });



    }

    // 批量删除购物车的商品
    function del_cart_more()
    {
        //if(!confirm('确定要删除吗?'))
        //  return false;

        $.artConfim('Are you sure you want to delete the selected item?', 'confimFrame', 'zh_cn', function (cancel) {
            if (cancel) {
                return false;
            }
        })
        // 循环获取复选框选中的值
        var chk_value = [];
        $('input[name^="cart_select"]:checked').each(function(){
            var s_name = $(this).attr('name');
            var id = s_name.replace('cart_select[','').replace(']','');
            chk_value.push(id);
        });
        // ajax  调用删除
        if(chk_value.length > 0)
            ajax_del_cart(chk_value.join(','));
    }
</script>
<script>
    $(function(){

        $('.gwc-gb').click( function () {
            //onclick="if(confirm('確定要刪除嗎?')) ajax_del_cart({$v.id});"
            var goodsId = $(this).attr('goods-id'),
                delGoodsTip = 'IsDelete <b style="color:#066">' + goodsId + '</b> The goods from the？'
            $.artConfim(delGoodsTip, 'confimFrame', 'zh_cn', function (cancel) {
                if (cancel) {
                    $.artTip('cancel', 800)
                } else {
                    $.artTip('confirm', 800)
                }
            })
        })
    });
</script>


<script>
    function set_exchange_rate(id){
        $.ajax({
            type: "POST",
            url: "{:U('Home/Index/ajax_set_exchange_rate')}",//+tab,
            data: {id: id}, //
            dataType: 'json',
            success: function () {
                location.reload();
            }
        });
    }

</script>